home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / BZIP2 / 980205 / bzip / Docs < prev    next >
Text File  |  1998-02-04  |  19KB  |  465 lines

  1.  
  2.  
  3.  
  4. bzip2(1)                                                 bzip2(1)
  5.  
  6.  
  7.        bzip2, bunzip2 - a block-sorting file compressor, v0.1
  8.        bzip2recover - recovers data from damaged bzip2 files
  9.  
  10.  
  11. SYNOPSIS
  12.        bzip2 [ -cdfkstvVL123456789 ] [ filenames ...  ]
  13.        bunzip2 [ -kvsVL ] [ filenames ...  ]
  14.        bzip2recover filename
  15.  
  16.  
  17. DESCRIPTION
  18.        Bzip2  compresses  files  using the Burrows-Wheeler block-
  19.        sorting text compression algorithm,  and  Huffman  coding.
  20.        Compression  is  generally  considerably  better than that
  21.        achieved by more conventional LZ77/LZ78-based compressors,
  22.        and  approaches  the performance of the PPM family of sta-
  23.        tistical compressors.
  24.  
  25.        The command-line options are deliberately very similar  to
  26.        those of GNU Gzip, but they are not identical.
  27.  
  28.        Bzip2  expects  a list of file names to accompany the com-
  29.        mand-line flags.  Each file is replaced  by  a  compressed
  30.        version  of  itself,  with  the  name "original_name.bz2".
  31.        Each compressed file has the same  modification  date  and
  32.        permissions  as  the corresponding original, so that these
  33.        properties can  be  correctly  restored  at  decompression
  34.        time.  File name handling is naive in the sense that there
  35.        is no mechanism for preserving original file  names,  per-
  36.        missions  and  dates  in filesystems which lack these con-
  37.        cepts, or have serious file name length restrictions, such
  38.        as MS-DOS.
  39.  
  40.        Bzip2  and  bunzip2  will not overwrite existing files; if
  41.        you want this to happen, you should delete them first.
  42.  
  43.        If no file names  are  specified,  bzip2  compresses  from
  44.        standard  input  to  standard output.  In this case, bzip2
  45.        will decline to write compressed output to a terminal,  as
  46.        this  would  be  entirely  incomprehensible  and therefore
  47.        pointless.
  48.  
  49.        Bunzip2 (or bzip2 -d ) decompresses and restores all spec-
  50.        ified files whose names end in ".bz2".  Files without this
  51.        suffix are ignored.  Again, supplying no filenames  causes
  52.        decompression from standard input to standard output.
  53.  
  54.        You  can also compress or decompress files to the standard
  55.        output by giving the -c flag.  You can decompress multiple
  56.        files  like  this, but you may only compress a single file
  57.        this way, since it would otherwise be difficult  to  sepa-
  58.        rate  out  the  compressed representations of the original
  59.        files.
  60.  
  61.  
  62.  
  63.                                                                 1
  64.  
  65.  
  66.  
  67.  
  68.  
  69. bzip2(1)                                                 bzip2(1)
  70.  
  71.  
  72.        Compression is always performed, even  if  the  compressed
  73.        file  is slightly larger than the original.  Files of less
  74.        than about one hundred bytes tend to get larger, since the
  75.        compression  mechanism  has  a  constant  overhead  in the
  76.        region of 50 bytes.  Random data (including the output  of
  77.        most  file  compressors)  is  coded at about 8.05 bits per
  78.        byte, giving an expansion of around 0.5%.
  79.  
  80.        As a self-check for your  protection,  bzip2  uses  32-bit
  81.        CRCs  to make sure that the decompressed version of a file
  82.        is identical to the original.  This guards against corrup-
  83.        tion  of  the compressed data, and against undetected bugs
  84.        in bzip2 (hopefully very unlikely).  The chances  of  data
  85.        corruption  going  undetected  is  microscopic,  about one
  86.        chance in four billion for each file processed.  Be aware,
  87.        though,  that  the  check occurs upon decompression, so it
  88.        can only tell you that that something is wrong.  It  can't
  89.        help  you recover the original uncompressed data.  You can
  90.        use bzip2recover to  try  to  recover  data  from  damaged
  91.        files.
  92.  
  93.        Return  values:  0  for a normal exit, 1 for environmental
  94.        problems (file not found, invalid flags, I/O errors,  &c),
  95.        2 to indicate a corrupt compressed file, 3 for an internal
  96.        consistency error (eg, bug) which caused bzip2 to panic.
  97.  
  98.  
  99. MEMORY MANAGEMENT
  100.        Bzip2 compresses large files in blocks.   The  block  size
  101.        affects  both  the  compression  ratio  achieved,  and the
  102.        amount of memory needed both for  compression  and  decom-
  103.        pression.   The flags -1 through -9 specify the block size
  104.        to be 100,000 bytes through 900,000  bytes  (the  default)
  105.        respectively.   At decompression-time, the block size used
  106.        for compression is read from the header of the  compressed
  107.        file, and bunzip2 then allocates itself just enough memory
  108.        to decompress the file.  Since block sizes are  stored  in
  109.        compressed  files,  it follows that the flags -1 to -9 are
  110.        irrelevant to and so ignored during  decompression.   Com-
  111.        pression  and decompression requirements, in bytes, can be
  112.        estimated as:
  113.  
  114.              Compression:   400k + ( 7 x block size )
  115.  
  116.              Decompression: 100k + ( 5 x block size ), or
  117.                             100k + ( 2.5 x block size )
  118.  
  119.        Larger  block  sizes  give  rapidly  diminishing  marginal
  120.        returns;  most of the compression comes from the first two
  121.        or three hundred k of block size, a fact worth bearing  in
  122.        mind  when  using  bzip2  on  small  machines.  It is also
  123.        important to  appreciate  that  the  decompression  memory
  124.        requirement  is  set  at compression-time by the choice of
  125.        block size.
  126.  
  127.  
  128.  
  129.                                                                 2
  130.  
  131.  
  132.  
  133.  
  134.  
  135. bzip2(1)                                                 bzip2(1)
  136.  
  137.  
  138.        For files compressed with the  default  900k  block  size,
  139.        bunzip2  will require about 4600 kbytes to decompress.  To
  140.        support decompression of any file on a 4 megabyte machine,
  141.        bunzip2  has  an  option to decompress using approximately
  142.        half this amount of memory, about 2300 kbytes.  Decompres-
  143.        sion  speed  is also halved, so you should use this option
  144.        only where necessary.  The relevant flag is -s.
  145.  
  146.        In general, try and use the largest block size memory con-
  147.        straints  allow,  since  that  maximises  the  compression
  148.        achieved.  Compression and decompression speed are  virtu-
  149.        ally unaffected by block size.
  150.  
  151.        Another  significant point applies to files which fit in a
  152.        single block -- that  means  most  files  you'd  encounter
  153.        using  a  large  block  size.   The  amount of real memory
  154.        touched is proportional to the size of the file, since the
  155.        file  is smaller than a block.  For example, compressing a
  156.        file 20,000 bytes long with the flag  -9  will  cause  the
  157.        compressor  to  allocate  around 6700k of memory, but only
  158.        touch 400k + 20000 * 7 = 540 kbytes of it.  Similarly, the
  159.        decompressor  will  allocate  4600k  but only touch 100k +
  160.        20000 * 5 = 200 kbytes.
  161.  
  162.        Here is a table which summarises the maximum memory  usage
  163.        for  different  block  sizes.   Also recorded is the total
  164.        compressed size for 14 files of the Calgary Text  Compres-
  165.        sion  Corpus totalling 3,141,622 bytes.  This column gives
  166.        some feel for how  compression  varies  with  block  size.
  167.        These  figures  tend to understate the advantage of larger
  168.        block sizes for larger files, since the  Corpus  is  domi-
  169.        nated by smaller files.
  170.  
  171.                   Compress   Decompress   Decompress   Corpus
  172.            Flag     usage      usage       -s usage     Size
  173.  
  174.             -1      1100k       600k         350k      914704
  175.             -2      1800k      1100k         600k      877703
  176.             -3      2500k      1600k         850k      860338
  177.             -4      3200k      2100k        1100k      846899
  178.             -5      3900k      2600k        1350k      845160
  179.             -6      4600k      3100k        1600k      838626
  180.             -7      5400k      3600k        1850k      834096
  181.             -8      6000k      4100k        2100k      828642
  182.             -9      6700k      4600k        2350k      828642
  183.  
  184.  
  185. OPTIONS
  186.        -c --stdout
  187.               Compress or decompress to standard output.  -c will
  188.               decompress multiple files to stdout, but will  only
  189.               compress a single file to stdout.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                 3
  196.  
  197.  
  198.  
  199.  
  200.  
  201. bzip2(1)                                                 bzip2(1)
  202.  
  203.  
  204.        -d --decompress
  205.               Force  decompression.  Bzip2 and bunzip2 are really
  206.               the same program, and the decision about whether to
  207.               compress  or  decompress  is  done  on the basis of
  208.               which name is used.  This flag overrides that mech-
  209.               anism, and forces bzip2 to decompress.
  210.  
  211.        -f --compress
  212.               The  complement  to -d: forces compression, regard-
  213.               less of the invokation name.
  214.  
  215.        -t --test
  216.               Check integrity of the specified file(s), but don't
  217.               decompress  them.   This  really  performs  a trial
  218.               decompression and throws away the result, using the
  219.               low-memory decompression algorithm (see -s).
  220.  
  221.        -k --keep
  222.               Keep  (don't delete) input files during compression
  223.               or decompression.
  224.  
  225.        -s --small
  226.               Reduce  memory  usage,  both  for  compression  and
  227.               decompression.  Files are decompressed using a mod-
  228.               ified algorithm which only requires 2.5  bytes  per
  229.               block  byte.   This  means  any  file can be decom-
  230.               pressed in 2300k of memory,  albeit  somewhat  more
  231.               slowly than usual.
  232.  
  233.               During  compression,  -s  selects  a  block size of
  234.               200k, which limits memory use to  around  the  same
  235.               figure,  at  the expense of your compression ratio.
  236.               In short, if your  machine  is  low  on  memory  (8
  237.               megabytes  or  less),  use  -s for everything.  See
  238.               MEMORY MANAGEMENT above.
  239.  
  240.  
  241.        -v --verbose
  242.               Verbose mode -- show the compression ratio for each
  243.               file  processed.   Further  -v's  increase the ver-
  244.               bosity level, spewing out lots of information which
  245.               is primarily of interest for diagnostic purposes.
  246.  
  247.        -L --license
  248.               Display  the  software  version,  license terms and
  249.               conditions.
  250.  
  251.        -V --version
  252.               Same as -L.
  253.  
  254.        -1 to -9
  255.               Set the block size to 100 k, 200 k ..  900  k  when
  256.               compressing.   Has  no  effect  when decompressing.
  257.               See MEMORY MANAGEMENT above.
  258.  
  259.  
  260.  
  261.                                                                 4
  262.  
  263.  
  264.  
  265.  
  266.  
  267. bzip2(1)                                                 bzip2(1)
  268.  
  269.  
  270.        --repetitive-fast
  271.               bzip2 injects some small  pseudo-random  variations
  272.               into  very  repetitive  blocks  to limit worst-case
  273.               performance during compression.   If  sorting  runs
  274.               into  difficulties,  the  block  is randomised, and
  275.               sorting is restarted.  Very roughly, bzip2 persists
  276.               for  three  times  as  long as a well-behaved input
  277.               would take before resorting to randomisation.  This
  278.               flag makes it give up much sooner.
  279.  
  280.  
  281.        --repetitive-best
  282.               Opposite  of  --repetitive-fast;  try  a lot harder
  283.               before resorting to randomisation.
  284.  
  285.  
  286. RECOVERING DATA FROM DAMAGED FILES
  287.        bzip2 compresses files in blocks, usually 900kbytes  long.
  288.        Each block is handled independently.  If a media or trans-
  289.        mission error causes a multi-block  .bz2  file  to  become
  290.        damaged,  it  may  be  possible  to  recover data from the
  291.        undamaged blocks in the file.
  292.  
  293.        The compressed representation of each block  is  delimited
  294.        by  a  48-bit pattern, which makes it possible to find the
  295.        block boundaries with reasonable  certainty.   Each  block
  296.        also  carries its own 32-bit CRC, so damaged blocks can be
  297.        distinguished from undamaged ones.
  298.  
  299.        bzip2recover is a  simple  program  whose  purpose  is  to
  300.        search  for blocks in .bz2 files, and write each block out
  301.        into its own .bz2 file.  You can then use bzip2 -t to test
  302.        the integrity of the resulting files, and decompress those
  303.        which are undamaged.
  304.  
  305.        bzip2recover takes a single argument, the name of the dam-
  306.        aged file, and writes a number of files "rec0001file.bz2",
  307.        "rec0002file.bz2", etc, containing the  extracted  blocks.
  308.        The output filenames are designed so that the use of wild-
  309.        cards in subsequent processing -- for example, "bzip2  -dc
  310.        rec*file.bz2  >  recovered_data" -- lists the files in the
  311.        "right" order.
  312.  
  313.        bzip2recover should be of most use dealing with large .bz2
  314.        files,  as  these will contain many blocks.  It is clearly
  315.        futile to use it on damaged single-block  files,  since  a
  316.        damaged  block  cannot  be recovered.  If you wish to min-
  317.        imise any potential data loss through media  or  transmis-
  318.        sion errors, you might consider compressing with a smaller
  319.        block size.
  320.  
  321.  
  322. PERFORMANCE NOTES
  323.        The sorting phase of compression gathers together  similar
  324.  
  325.  
  326.  
  327.                                                                 5
  328.  
  329.  
  330.  
  331.  
  332.  
  333. bzip2(1)                                                 bzip2(1)
  334.  
  335.  
  336.        strings  in  the  file.  Because of this, files containing
  337.        very long runs of  repeated  symbols,  like  "aabaabaabaab
  338.        ..."   (repeated   several  hundred  times)  may  compress
  339.        extraordinarily slowly.  You can use the -vvvvv option  to
  340.        monitor progress in great detail, if you want.  Decompres-
  341.        sion speed is unaffected.
  342.  
  343.        Such pathological cases seem rare in  practice,  appearing
  344.        mostly in artificially-constructed test files, and in low-
  345.        level disk images.  It may be inadvisable to use bzip2  to
  346.        compress  the  latter.   If you do get a file which causes
  347.        severe slowness in compression, try making the block  size
  348.        as small as possible, with flag -1.
  349.  
  350.        Incompressible or virtually-incompressible data may decom-
  351.        press rather more slowly than one would hope.  This is due
  352.        to a naive implementation of the move-to-front coder.
  353.  
  354.        bzip2  usually  allocates  several  megabytes of memory to
  355.        operate in, and then charges all over it in a fairly  ran-
  356.        dom  fashion.   This means that performance, both for com-
  357.        pressing and decompressing, is largely determined  by  the
  358.        speed  at  which  your  machine  can service cache misses.
  359.        Because of this, small changes to the code to  reduce  the
  360.        miss  rate  have  been observed to give disproportionately
  361.        large performance improvements.  I imagine bzip2 will per-
  362.        form best on machines with very large caches.
  363.  
  364.        Test mode (-t) uses the low-memory decompression algorithm
  365.        (-s).  This means test mode does not run  as  fast  as  it
  366.        could;  it  could  run as fast as the normal decompression
  367.        machinery.  This could easily be fixed at the cost of some
  368.        code bloat.
  369.  
  370.  
  371. CAVEATS
  372.        I/O  error  messages  are not as helpful as they could be.
  373.        Bzip2 tries hard to detect I/O errors  and  exit  cleanly,
  374.        but  the  details  of  what  the problem is sometimes seem
  375.        rather misleading.
  376.  
  377.        This manual page pertains to version 0.1 of bzip2.  It may
  378.        well  happen that some future version will use a different
  379.        compressed file format.  If you try to  decompress,  using
  380.        0.1,  a  .bz2  file created with some future version which
  381.        uses a different compressed file format, 0.1 will complain
  382.        that  your  file  "is not a bzip2 file".  If that happens,
  383.        you should obtain a more recent version of bzip2  and  use
  384.        that to decompress the file.
  385.  
  386.        Wildcard expansion for Windows 95 and NT is flaky.
  387.  
  388.        bzip2recover  uses  32-bit integers to represent bit posi-
  389.        tions in compressed files, so it cannot handle  compressed
  390.  
  391.  
  392.  
  393.                                                                 6
  394.  
  395.  
  396.  
  397.  
  398.  
  399. bzip2(1)                                                 bzip2(1)
  400.  
  401.  
  402.        files  more than 512 megabytes long.  This could easily be
  403.        fixed.
  404.  
  405.        bzip2recover sometimes reports a  very  small,  incomplete
  406.        final  block.  This is spurious and can be safely ignored.
  407.  
  408.  
  409. RELATIONSHIP TO bzip-0.21
  410.        This program is a descendant of the bzip program,  version
  411.        0.21,  which  I released in August 1996.  The primary dif-
  412.        ference of bzip2 is its avoidance of the possibly patented
  413.        algorithms  which  were  used  in 0.21.  bzip2 also brings
  414.        various useful refinements (-s,  -t),  uses  less  memory,
  415.        decompresses  significantly  faster,  and  has support for
  416.        recovering data from damaged files.
  417.  
  418.        Because bzip2 uses Huffman coding to  construct  the  com-
  419.        pressed  bitstream, rather than the arithmetic coding used
  420.        in 0.21, the compressed representations generated  by  the
  421.        two  programs are incompatible, and they will not interop-
  422.        erate.  The change in suffix from  .bz  to  .bz2  reflects
  423.        this.   It would have been helpful to at least allow bzip2
  424.        to decompress files created by 0.21, but this would defeat
  425.        the primary aim of having a patent-free compressor.
  426.  
  427.        For a more precise statement about patent issues in bzip2,
  428.        please see the README file in the distribution.
  429.  
  430.        Huffman  coding  necessarily  involves some coding ineffi-
  431.        ciency compared to arithmetic  coding.   This  means  that
  432.        bzip2  compresses about 1% worse than 0.21, an unfortunate
  433.        but unavoidable fact-of-life.  On the other  hand,  decom-
  434.        pression  is approximately 50% faster for the same reason,
  435.        and the change in file format gave an opportunity  to  add
  436.        data-recovery features.  So it is not all bad.
  437.  
  438.  
  439. AUTHOR
  440.        Julian Seward, jseward@acm.org.
  441.  
  442.        The ideas embodied in bzip and bzip2 are due to (at least)
  443.        the following people: Michael Burrows  and  David  Wheeler
  444.        (for  the  block  sorting  transformation),  David Wheeler
  445.        (again, for the Huffman coder),  Peter  Fenwick  (for  the
  446.        structured  coding  model  in 0.21, and many refinements),
  447.        and Alistair Moffat, Radford Neal and Ian Witten (for  the
  448.        arithmetic  coder  in 0.21).  I am much indebted for their
  449.        help, support and advice.  See the file ALGORITHMS in  the
  450.        source  distribution for pointers to sources of documenta-
  451.        tion.  Christian von Roques  encouraged  me  to  look  for
  452.        faster  sorting algorithms, so as to speed up compression.
  453.        Bela Lubkin encouraged me to improve the  worst-case  com-
  454.        pression  performance.   Many  people sent patches, helped
  455.        with portability problems, lent machines, gave advice  and
  456.        were generally helpful.
  457.  
  458.  
  459.  
  460.  
  461.  
  462.                                                                 7
  463.  
  464.  
  465.